package cn.kgm.abstractFactory;

import cn.kgm.abstractFactory.color.Color;
import cn.kgm.abstractFactory.shape.Shape;

/**
 * 抽象工厂模式
 */
public class AbstractFactoryPatternDemo {
    public static void main(String[] args) {
        String[] producer = new String[]{"SHAPE", "COLOR"};
        String[] shape = new String[]{"CIRCLE"};
        String[] color = new String[]{"BLUE"};

        for (String s : producer) {
            AbstractFactory abstractFactory = FactoryProducer.getAbstractFactory(s);
            if (abstractFactory instanceof ColorFactory) {
                Color factoryColor = abstractFactory.getColor(color[0]);
                factoryColor.fill();
            }
            if (abstractFactory instanceof ShapeFactory) {
                Shape shapeFactory = abstractFactory.getShape(shape[0]);
                shapeFactory.draw();
            }
        }
    }
}
